/***************************************************************************
 *   Copyright (C) 2010 by programmeboy                                    *
 *   programmeboy@gmail.com                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.                                        *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
 ***************************************************************************/

#ifndef __GUI_H__
#define __GUI_H__

#include <ntddk.h>
#include "fonts.h"

#define OUTPUT_INFO			"VMXDBG 0.0.1 BY ProgrammeBoy"
#define OUTPUT_WEBSITE		"Website: Http://code.google.com/p/vmxdbg"
#define INPUT_FLAG			"CMD >"
#define GUI_LOGO			"[ VMXDBG ]"
#define BYTES_PER_PIXEL	4
#define GUI_WIDTH		800
#define GUI_HEIGTH		600

//(GUI_WIDTH/FONT_WIDTH)
//(GUI_HEIGTH/FONT_HEIGHT)
#define GUI_FRAME_WIDTH		100
#define GUI_FRAME_HEIGTH	37

#define BLACK       0x00000000
#define WHITE       0xffffffff
#define VOMIT_GREEN 0x0000c618
#define LIGHT_GREEN 0x0000f800
#define LIGHT_BLUE  0x00009cd3
#define DARK_BLUE   0x00000780
#define BLUE        0x000044b0
#define CYAN        0x0000ffe0
#define RED         0xffff0000
#define BGCOLOR     BLACK
#define VIDEO_WRITE(_Addr, _Value) *(ULONG *)_Addr = _Value

typedef struct _MACHINE_VIDEO_INFO
{
	ULONG Width;
	ULONG Heigth;
	ULONG Stride;
	ULONG MemSize;
	PVOID VideoVirtualAddress;
	PHYSICAL_ADDRESS VideoPhysicalAddrss;
	PVOID SavedScreen;

}MACHINE_VIDEO_INFO, *PMACHINE_VIDEO_INFO;

#define LINE_MAX_STRING_LEN		GUI_FRAME_WIDTH - 3

#define STRIP_LINE1		4
#define STRIP_LINE2		25

#define INPUT_WINDOW_MAX_INPUT		91
#define INPUT_WINDOW_STARTX			8
#define INPUT_LINE_NUMBER			35
#define OUTPUT_WINDOW_STARTLINE		26
#define OUTPUT_WINDOW_ENDLINE		33
#define OUTPUT_WINDOW_TOTALLINE		8

#define DIASM_WINDOW_STARTLINE		5
#define DIASM_WINDOW_ENDLINE		24
#define DIASM_WINDOW_TOTALLINE		20

#define REG_WINDOW_STARTLINE	1
#define REG_WINDOW_ENDLINE		3
#define REG_WINDOW_TOTALLINE	3

#define GUIDrawCharactor(_c, _color, _x, _y) \
		GUIDrawCharactorWithBkColor(_c, _color, _x, _y, TRUE, BGCOLOR)

VOID
GUIDrawCharactorWithBkColor(
		UCHAR CharPrint,
		ULONG Color,
		ULONG ScreenX,
		ULONG ScreenY,
		BOOLEAN bTransparent,
		ULONG BkColor
);

#define GUIDrawString(_str, _len, _color, _x, _y) \
		GUIDrawStringWithBkColor(_str, _len, _color, _x, _y, TRUE, BGCOLOR)
VOID 
GUIDrawStringWithBkColor(
		PUCHAR String, 
		ULONG Length, 
		ULONG Color, 
		ULONG ScreenX, 
		ULONG ScreenY, 
		BOOLEAN bTransparent, 
		ULONG BkColor
);

PMACHINE_VIDEO_INFO
GUIGetVideoInfo(
	VOID
);

VOID
GUISetLeaveDebug(
   VOID				
   );

VOID
GUISetEnterDebug(
   VOID				
   );

VOID
GUIEntryDebug(
  PCPU_VM_CONTEXT pCPU,
  PSAVED_REGISTOR pSavedReg
  );

NTSTATUS
GUIInitVideoInfo(
 VOID
 );

VOID
GUIReleaseVideoInfo(
	VOID
);

#define PutStringToOutputWindow(_s, _l, _c) \
		PutStringToOutputWindowWithBkColor(_s, _l, _c, TRUE, BGCOLOR);
VOID
PutStringToOutputWindowWithBkColor(
		PUCHAR String,
		ULONG Length,
		ULONG Color,
		BOOLEAN bTransparent,
		ULONG BkColor
);

VOID
UpdataCmdInputWindow(
		PUCHAR CmdStr,
		ULONG Length
);

VOID
InitDasmEngine(
);

VOID
GUIShowDasm(
);

VOID
GUIDrawRegister(
	PSAVED_REGISTOR pSavedReg
);

#endif